package com.pdstudio.carrecom.ui.adapter;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.pdstudio.carrecom.bean.CarSelectInfo;
import com.pdstudio.carrecom.bean.City;
import com.pdstudio.carrecom.ui.view.PinnedHeaderListView;
import com.pdstudio.carrecom.ui.view.PinnedHeaderListView.PinnedHeaderAdapter;
import com.pdstudio.carrecom.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.BaseAdapter;
import android.widget.SectionIndexer;
import android.widget.TextView;


/**
 * 
 * 类: SelectAdapter <br>
 * 描述: 选择界面适配器 <br>
 * 作者: ws  <br>
 * 时间: 2015-6-30 下午8:25:37
 */
public class SelectAdapter extends BaseAdapter implements 
		OnScrollListener {
	private List<CarSelectInfo> mCities;
	private LayoutInflater inflater;

	public SelectAdapter(Context context, List<CarSelectInfo> cities) {
		inflater = LayoutInflater.from(context);
		mCities = cities;
	}

	@Override
	public int getCount() {
		return mCities.size();
	}

	@Override
	public CarSelectInfo getItem(int position) {
		return mCities.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		ViewHolder viewHolder = null;
		
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.search_city_item, null);
			
			viewHolder = new ViewHolder();
			viewHolder.mName = (TextView) convertView.findViewById(R.id.search_province);
			viewHolder.mEmpty = (TextView) convertView.findViewById(R.id.column_title);
			viewHolder.mEmpty.setVisibility(View.GONE);
			
			convertView.setTag(viewHolder);
		}
		else{
			viewHolder = (ViewHolder) convertView.getTag();
		}
		
		CarSelectInfo item = mCities.get(position);
		
		viewHolder.mName.setText(item.name);
		
		return convertView;
	}

	@Override
	public void onScrollStateChanged(AbsListView view, int scrollState) {

	}

	@Override
	public void onScroll(AbsListView view, int firstVisibleItem,
			int visibleItemCount, int totalItemCount) {

	}
	
	public class ViewHolder{
		private TextView mName;
		private TextView mEmpty;
	}


}
